import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Test {

    //创建小根堆
    public void createHeap(int[] arr) {
        /*for (int parent = (arr.length - 1 - 1) / 2; parent >= 0; parent--) {
            shirtDown(parent, arr, arr.length);
        }*/

        for (int child = arr.length - 1; child > 0; child--) {
            shirtUp(child,arr,arr.length);
        }
    }

    private void shirtDown(int parent, int[] arr, int size) {
        int child = 2 * parent + 1;//左孩子
        while(child < size) {
            if(child + 1 < size && arr[child + 1] < arr[child]) {
                child++;
            }
            if(arr[child] < arr[parent]) {
                swap(child,parent,arr);
                parent = child;
                child = 2 * parent + 1;
            } else {
                break;
            }
        }
    }

    private void swap(int child, int parent, int[] arr) {
        int tmp = arr[child];
        arr[child] = arr[parent];
        arr[parent] = tmp;
    }

    private void shirtUp(int child, int[] arr, int size) {
        int parent = (child - 1) / 2;
        while(parent >= 0) {
            if(child + 1 < size && arr[child+1] < arr[child]) {
                child++;
            }
            if(arr[parent] > arr[child]) {
                swap(parent,child,arr);
                child = parent;
                parent = (child - 1) / 2;
            } else {
                break;
            }
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int m = in.nextInt();
        int q = in.nextInt();
        int[][] arr = new int[n][m];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                arr[i][j] = in.nextInt();
            }
        }

        //构建前缀和数组
        long[][] dp = new long[n+1][m+1];
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1] + arr[i-1][j-1];
            }
        }

        while(q > 0) {
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            System.out.println(dp[x2][y2] - (dp[x1-1][y2] + dp[x2][y1-1] - dp[x1-1][y1-1]));
            q--;
        }
    }

    public int pivotIndex(int[] nums) {
        int n = nums.length;
        int[] f = new int[n];
        int[] g = new int[n];

        //构建前缀和数组
        for(int i = 1; i < n; i++) {
            f[i] = f[i-1] + nums[i-1];
        }

        //构建后缀和数组
        for(int i = n-2; i >= 0; i--) {
            g[i] = g[i+1] + nums[i+1];
        }

        //查找
        for(int i = 0; i < n; i++) {
            if(f[i] == g[i]) {
                return i;
            }
        }

        return -1;
    }

    public static void main1(String[] args) {
        int[] arr = {5,8,4,6,0,7,10,2};
        Test test = new Test();
        test.createHeap(arr);
        System.out.println(Arrays.toString(arr));
        PriorityQueue<Integer> queue = new PriorityQueue<>();
    }
}
